package com.gxan.renshiservice.impl;

import com.gxan.pojo.Archives;
import com.gxan.renshidao.ArchivesDao;
import com.gxan.renshidao.impl.ArchivesDaoImpl;
import com.gxan.renshiservice.ServiceArchives;

import java.sql.SQLException;
import java.util.List;

public class ServiceArchivesImpl implements ServiceArchives {
    public List<Archives> findAllArchives(Integer page, Integer limit) throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer offset = (page-1)*limit;
        Integer rows =limit;
        return   archivesDao.findAllArchives(offset,rows);
    }

    @Override
    public Integer countArchives() throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer num = archivesDao.countArchives();
        return num;
    }

    @Override
    public Integer addArchives(Archives archives) throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer num = archivesDao.addArcives(archives);
        return num;
    }

    @Override
    public List<Archives> searchArchives(String archives_id, String audit_status, String status , String s_date,String t_date,Integer page, Integer limit) throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer offset = (page-1)*limit;
        Integer rows = limit;
        List<Archives> list = archivesDao.searchArchives(archives_id,audit_status,status,s_date,t_date,offset,rows);
        return list;
    }

    @Override
    public Integer countArchivesByCoundition(String archives_id, String audit_status, String status, String s_date,String t_date) throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer num = archivesDao.countArchivesByCondition(archives_id,audit_status,status,s_date,t_date);
        return num;
    }

    @Override
    public Integer delArchives(Integer archives_id) throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer num = archivesDao.delArchives(archives_id);
        return num;
    }

    @Override
    public Integer updateArchives(Archives archives) throws SQLException {
        ArchivesDao archivesDao = new ArchivesDaoImpl();
        Integer num = archivesDao.updateArchives(archives);
        return num;
    }

}
